package com.xbongbong.pro.rabbitmq.producer.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.message.pojo.dto.AutoClueAssignmentRabbitMqDTO;
import com.xbongbong.pro.message.pojo.dto.PublicGroupRabbitMqDTO;
import com.xbongbong.pro.rabbitmq.binders.AutoClueAssignmentProducerBinder;
import com.xbongbong.pro.rabbitmq.binders.PublicGroupProducerBinder;
import com.xbongbong.pro.rabbitmq.producer.AutoClueAssignmentProducer;
import com.xbongbong.pro.rabbitmq.producer.PublicGroupProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lijiangren
 * @version v1.0
 * @date 2022/05/17 19:53
 * @since v1.0
 */
@Service("publicGroupProducer")
@EnableBinding(PublicGroupProducerBinder.class)
public class PublicGroupProducerImpl implements PublicGroupProducer {

    @Resource
    private PublicGroupProducerBinder publicGroupProducerBinder;

    @Override
    public void bindPublicGroup(PublicGroupRabbitMqDTO publicGroupRabbitMqDTO) throws XbbException {
        MessageBuilder messageBuilder = MessageBuilder.withPayload(publicGroupRabbitMqDTO);
        publicGroupProducerBinder.bindPublicGroupProducerOutput().send(messageBuilder.build());
    }
}
